<?php
require_once 'classes/Login.php';
$Login = new Login;
/*Must be Admin to access these methods*/
if(($Login->superUser($_SESSION['employerID']))) {
	
	switch($_GET['action'])
	{
		//Upgrade to Admin Privs
		case 'promoteUser':
			$userId = $_GET['id'];
			require_once 'classes/Employer.php';
			$Employer = new Employer;
			if($message = $Employer->promoteUser($userId))
			{
			   echo $message;
			}
		  /* print "Promoted";*/
		break;
		
		//Upgrade to Admin Privs
		case 'demoteUser':
			$userId = $_GET['id'];
			require_once 'classes/Employer.php';
			$Employer = new Employer;
			if($message = $Employer->demoteUser($userId))
			{
			   echo $message;
			}
		  /* print "Promoted";*/
		break;
		
		//Remove From Active User List
		case 'removeUser':
			$userId = $_GET['id'];
			require_once 'classes/Employer.php';
			$Employer = new Employer;
			if($message = $Employer->removeUser($userId))
			{
			   echo $message;
			}
		    if($message = $Employer->removeAllPosts($userId))
			{
			   echo $message;
			}
		break;	
		
		//Repost Specific Job Post ------------------------------------------------------------------------
		case 'RepostJob':
			if(!empty($_GET['postId']))
			{
				$id = strip_tags($_GET['postId']);
				
				require_once 'classes/JobPost.php';
				$JobPost = new JobPost;
				if($message = $JobPost->repostJob($id))
				{
						echo $message;
				}
			}
			else { /*Error*/ }
		break;
		
		//Restore to Active User List
		case 'restoreUser':
			$userId = $_GET['id'];
			require_once 'classes/Employer.php';
			$Employer = new Employer;
			if($message = $Employer->restoreUser($userId))
			{
			   echo $message;
			}
		    if($message = $Employer->restoreAllPosts($userId))
			{
			   echo $message;
			}
		break;	
		
		//Restore to Active User List
		case 'removeOnePost':
			$postId = $_GET['id'];
			require_once 'classes/JobPost.php';
			$JobPost = new JobPost;
			if($message = $JobPost->removeOnePost($postId))
			{
			   echo $message;
			}
		break;	
	}
}
else {
header('location:index.php');
}
?>